unit SYS_WF_CURRENT_TASKS;


interface
uses
  Classes,SysUtils,DB,Uni,UniEngine;

type
  TSYSWFCURRENTTASKS=class(TUniEngine)
  private
    FTASKID   : Extended;
    FWFID     : Extended;
    FWFTABLENAME: string;
    FENTITYID : string;
    FCURRENTNODEID: Extended;
    FNEXTNODEID: Extended;
    FACTIONTYPECODE: string;
    FISUNDO   : Extended;
    FCREATEUSER: string;
    FCREATEDATE: string;
    FUNDOUSER : string;
    FUNDODATE : string;
    FOPERATIONNAME: string;
    FOPERATIONDATE: string;
    FOPERATIONREMARK: string;
    FINITMONEY: Extended;
    FRESULTMONEY: Extended;
    FREMARK   : string;
    FTOLLYFLAG: Extended;
    FBILLTYPECODE: string;
    FBILLID   : string;
    FRCID     : Extended;
    FCCID     : Extended;
    FLASTVER  : string;
    FSENDMSGDATE: string;
    FAUTOAUDITDATE: string;
    FSETMONTH : Extended;
    FUPDATEFLAG: Extended;
  protected
    procedure SetParameters;override;
    function  GetStrInsert:string;override;
    function  GetStrUpdate:string;override;
    function  GetStrDelete:string;override;
  public
    function  GetStrsIndex:string;override;
  public
    function  GetNextIdex:Integer;overload;
    function  GetNextIdex(AUniConnection:TUniConnection):Integer;overload;
  public
    function  CheckExist(AUniConnection:TUniConnection):Boolean;override;
  public
    destructor  Destroy; override;
    constructor Create;  
  published
    property TASKID   : Extended read FTASKID    write FTASKID;
    property WFID     : Extended read FWFID      write FWFID;
    property WFTABLENAME: string read FWFTABLENAME write FWFTABLENAME;
    property ENTITYID : string read FENTITYID  write FENTITYID;
    property CURRENTNODEID: Extended read FCURRENTNODEID write FCURRENTNODEID;
    property NEXTNODEID: Extended read FNEXTNODEID write FNEXTNODEID;
    property ACTIONTYPECODE: string read FACTIONTYPECODE write FACTIONTYPECODE;
    property ISUNDO   : Extended read FISUNDO    write FISUNDO;
    property CREATEUSER: string read FCREATEUSER write FCREATEUSER;
    property CREATEDATE: string read FCREATEDATE write FCREATEDATE;
    property UNDOUSER : string read FUNDOUSER  write FUNDOUSER;
    property UNDODATE : string read FUNDODATE  write FUNDODATE;
    property OPERATIONNAME: string read FOPERATIONNAME write FOPERATIONNAME;
    property OPERATIONDATE: string read FOPERATIONDATE write FOPERATIONDATE;
    property OPERATIONREMARK: string read FOPERATIONREMARK write FOPERATIONREMARK;
    property INITMONEY: Extended read FINITMONEY write FINITMONEY;
    property RESULTMONEY: Extended read FRESULTMONEY write FRESULTMONEY;
    property REMARK   : string read FREMARK    write FREMARK;
    property TOLLYFLAG: Extended read FTOLLYFLAG write FTOLLYFLAG;
    property BILLTYPECODE: string read FBILLTYPECODE write FBILLTYPECODE;
    property BILLID   : string read FBILLID    write FBILLID;
    property RCID     : Extended read FRCID      write FRCID;
    property CCID     : Extended read FCCID      write FCCID;
    property LASTVER  : string read FLASTVER   write FLASTVER;
    property SENDMSGDATE: string read FSENDMSGDATE write FSENDMSGDATE;
    property AUTOAUDITDATE: string read FAUTOAUDITDATE write FAUTOAUDITDATE;
    property SETMONTH : Extended read FSETMONTH  write FSETMONTH;
    property UPDATEFLAG: Extended read FUPDATEFLAG write FUPDATEFLAG;    
  public
    class function  ReadDS(AUniQuery:TUniQuery):TUniEngine;override;
    class procedure ReadDS(AUniQuery:TUniQuery;var Result:TUniEngine);override;
    class function  CopyIt(ASYSWFCURRENTTASKS:TSYSWFCURRENTTASKS):TSYSWFCURRENTTASKS;overload;        
    class procedure CopyIt(ASYSWFCURRENTTASKS:TSYSWFCURRENTTASKS;var Result:TSYSWFCURRENTTASKS);overload;       
  end;

implementation

{ TSYSWFCURRENTTASKS }
procedure TSYSWFCURRENTTASKS.SetParameters;
begin
  inherited;
  with FUniSQL.Params do
  begin
    case FOptTyp of
      otAddx:
      begin
        ParamByName('TASK_ID').Value := TASKID;
        ParamByName('WF_ID').Value := WFID;
        ParamByName('WF_TABLE_NAME').Value := WFTABLENAME;
        ParamByName('ENTITY_ID').Value := ENTITYID;
        ParamByName('CURRENT_NODE_ID').Value := CURRENTNODEID;
        ParamByName('NEXT_NODE_ID').Value := NEXTNODEID;
        ParamByName('ACTION_TYPE_CODE').Value := ACTIONTYPECODE;
        ParamByName('IS_UNDO').Value := ISUNDO;
        ParamByName('CREATE_USER').Value := CREATEUSER;
        ParamByName('CREATE_DATE').Value := CREATEDATE;
        ParamByName('UNDO_USER').Value := UNDOUSER;
        ParamByName('UNDO_DATE').Value := UNDODATE;
        ParamByName('OPERATION_NAME').Value := OPERATIONNAME;
        ParamByName('OPERATION_DATE').Value := OPERATIONDATE;
        ParamByName('OPERATION_REMARK').Value := OPERATIONREMARK;
        ParamByName('INIT_MONEY').Value := INITMONEY;
        ParamByName('RESULT_MONEY').Value := RESULTMONEY;
        ParamByName('REMARK').Value := REMARK;
        ParamByName('TOLLY_FLAG').Value := TOLLYFLAG;
        ParamByName('BILL_TYPE_CODE').Value := BILLTYPECODE;
        ParamByName('BILL_ID').Value := BILLID;
        ParamByName('RCID').Value := RCID;
        ParamByName('CCID').Value := CCID;
        ParamByName('LAST_VER').Value := LASTVER;
        ParamByName('SEND_MSG_DATE').Value := SENDMSGDATE;
        ParamByName('AUTO_AUDIT_DATE').Value := AUTOAUDITDATE;
        ParamByName('SET_MONTH').Value := SETMONTH;
        ParamByName('UPDATE_FLAG').Value := UPDATEFLAG; 
      end;
      otEdit:
      begin
        ParamByName('TASK_ID').Value := TASKID;
        ParamByName('WF_ID').Value := WFID;
        ParamByName('WF_TABLE_NAME').Value := WFTABLENAME;
        ParamByName('ENTITY_ID').Value := ENTITYID;
        ParamByName('CURRENT_NODE_ID').Value := CURRENTNODEID;
        ParamByName('NEXT_NODE_ID').Value := NEXTNODEID;
        ParamByName('ACTION_TYPE_CODE').Value := ACTIONTYPECODE;
        ParamByName('IS_UNDO').Value := ISUNDO;
        ParamByName('CREATE_USER').Value := CREATEUSER;
        ParamByName('CREATE_DATE').Value := CREATEDATE;
        ParamByName('UNDO_USER').Value := UNDOUSER;
        ParamByName('UNDO_DATE').Value := UNDODATE;
        ParamByName('OPERATION_NAME').Value := OPERATIONNAME;
        ParamByName('OPERATION_DATE').Value := OPERATIONDATE;
        ParamByName('OPERATION_REMARK').Value := OPERATIONREMARK;
        ParamByName('INIT_MONEY').Value := INITMONEY;
        ParamByName('RESULT_MONEY').Value := RESULTMONEY;
        ParamByName('REMARK').Value := REMARK;
        ParamByName('TOLLY_FLAG').Value := TOLLYFLAG;
        ParamByName('BILL_TYPE_CODE').Value := BILLTYPECODE;
        ParamByName('BILL_ID').Value := BILLID;
        ParamByName('RCID').Value := RCID;
        ParamByName('CCID').Value := CCID;
        ParamByName('LAST_VER').Value := LASTVER;
        ParamByName('SEND_MSG_DATE').Value := SENDMSGDATE;
        ParamByName('AUTO_AUDIT_DATE').Value := AUTOAUDITDATE;
        ParamByName('SET_MONTH').Value := SETMONTH;
        ParamByName('UPDATE_FLAG').Value := UPDATEFLAG; 
      end;  
      otDelt:
      begin
        ParamByName('TASK_ID').Value := TASKID;
 
      end;  
    end;
  end;
end;

function TSYSWFCURRENTTASKS.CheckExist(AUniConnection: TUniConnection): Boolean;
begin
  Result:=CheckExist('SYS_WF_CURRENT_TASKS',['TASK_ID',TASKID],AUniConnection);
end;

function TSYSWFCURRENTTASKS.GetNextIdex: Integer;
begin

end;

function TSYSWFCURRENTTASKS.GetNextIdex(AUniConnection: TUniConnection): Integer;
var
  SQLA:string;
begin
  //Result:=CheckField('TASK_ID','SYS_WF_CURRENT_TASKS',[],AUniConnection);
  Result:=CheckField('SELECT SEQ_SYS_WF_TASK_ID.NEXTVAL FROM DUAL','NEXTVAL',AUniConnection);
end;

function TSYSWFCURRENTTASKS.GetStrDelete: string;
begin
  Result:='DELETE FROM SYS_WF_CURRENT_TASKS WHERE   TASK_ID=:TASK_ID';
end;

function TSYSWFCURRENTTASKS.GetStrInsert: string;
begin
  Result:='INSERT INTO SYS_WF_CURRENT_TASKS'
         +'    ( TASK_ID, WF_ID, WF_TABLE_NAME, ENTITY_ID, CURRENT_NODE_ID'
         +'    , NEXT_NODE_ID, ACTION_TYPE_CODE, IS_UNDO, CREATE_USER'
         +'    , CREATE_DATE, UNDO_USER, UNDO_DATE, OPERATION_NAME'
         +'    , OPERATION_DATE, OPERATION_REMARK, INIT_MONEY, RESULT_MONEY'
         +'    , REMARK, TOLLY_FLAG, BILL_TYPE_CODE, BILL_ID, RCID'
         +'    , CCID, LAST_VER, SEND_MSG_DATE, AUTO_AUDIT_DATE, SET_MONTH'
         +'    , UPDATE_FLAG)'
         +'    VALUES'
         +'    (:TASK_ID,:WF_ID,:WF_TABLE_NAME,:ENTITY_ID,:CURRENT_NODE_ID'
         +'    ,:NEXT_NODE_ID,:ACTION_TYPE_CODE,:IS_UNDO,:CREATE_USER'
         +'    ,:CREATE_DATE,:UNDO_USER,:UNDO_DATE,:OPERATION_NAME'
         +'    ,:OPERATION_DATE,:OPERATION_REMARK,:INIT_MONEY,:RESULT_MONEY'
         +'    ,:REMARK,:TOLLY_FLAG,:BILL_TYPE_CODE,:BILL_ID,:RCID'
         +'    ,:CCID,:LAST_VER,:SEND_MSG_DATE,:AUTO_AUDIT_DATE,:SET_MONTH'
         +'    ,:UPDATE_FLAG)';
end;

function TSYSWFCURRENTTASKS.GetStrsIndex: string;
begin
  Result:=Format('',[]);
end;

function TSYSWFCURRENTTASKS.GetStrUpdate: string;
begin
  Result:='UPDATE  SYS_WF_CURRENT_TASKS SET'
         +'    WF_ID=:WF_ID,'
         +'    WF_TABLE_NAME=:WF_TABLE_NAME,'
         +'    ENTITY_ID=:ENTITY_ID,'
         +'    CURRENT_NODE_ID=:CURRENT_NODE_ID,'
         +'    NEXT_NODE_ID=:NEXT_NODE_ID,'
         +'    ACTION_TYPE_CODE=:ACTION_TYPE_CODE,'
         +'    IS_UNDO=:IS_UNDO,'
         +'    CREATE_USER=:CREATE_USER,'
         +'    CREATE_DATE=:CREATE_DATE,'
         +'    UNDO_USER=:UNDO_USER,'
         +'    UNDO_DATE=:UNDO_DATE,'
         +'    OPERATION_NAME=:OPERATION_NAME,'
         +'    OPERATION_DATE=:OPERATION_DATE,'
         +'    OPERATION_REMARK=:OPERATION_REMARK,'
         +'    INIT_MONEY=:INIT_MONEY,'
         +'    RESULT_MONEY=:RESULT_MONEY,'
         +'    REMARK=:REMARK,'
         +'    TOLLY_FLAG=:TOLLY_FLAG,'
         +'    BILL_TYPE_CODE=:BILL_TYPE_CODE,'
         +'    BILL_ID=:BILL_ID,'
         +'    RCID=:RCID,'
         +'    CCID=:CCID,'
         +'    LAST_VER=:LAST_VER,'
         +'    SEND_MSG_DATE=:SEND_MSG_DATE,'
         +'    AUTO_AUDIT_DATE=:AUTO_AUDIT_DATE,'
         +'    SET_MONTH=:SET_MONTH,'
         +'    UPDATE_FLAG=:UPDATE_FLAG'
         +'    WHERE TASK_ID=:TASK_ID';
end;

constructor TSYSWFCURRENTTASKS.Create;
begin

end;

destructor TSYSWFCURRENTTASKS.Destroy;
begin

  inherited;
end;

class function TSYSWFCURRENTTASKS.ReadDS(AUniQuery: TUniQuery): TUniEngine;
var
  I:Integer;
  Field:TField;
  FieldName:string;
begin
  Result:=TSYSWFCURRENTTASKS.Create;

  with TSYSWFCURRENTTASKS(Result) do
  begin
    for I:=0 to AUniQuery.Fields.Count-1 do
    begin
      Field:=AUniQuery.Fields.Fields[I];
      //if field.fieldname is not all uppercase,please use uppercase().
      FieldName:=Field.FieldName;
      if FieldName='TASK_ID' then
      begin
        TASKID   :=Field.AsFloat;
      end else
      if FieldName='WF_ID' then
      begin
        WFID     :=Field.AsFloat;
      end else
      if FieldName='WF_TABLE_NAME' then
      begin
        WFTABLENAME:=Field.AsString;
      end else
      if FieldName='ENTITY_ID' then
      begin
        ENTITYID :=Field.AsString;
      end else
      if FieldName='CURRENT_NODE_ID' then
      begin
        CURRENTNODEID:=Field.AsFloat;
      end else
      if FieldName='NEXT_NODE_ID' then
      begin
        NEXTNODEID:=Field.AsFloat;
      end else
      if FieldName='ACTION_TYPE_CODE' then
      begin
        ACTIONTYPECODE:=Field.AsString;
      end else
      if FieldName='IS_UNDO' then
      begin
        ISUNDO   :=Field.AsFloat;
      end else
      if FieldName='CREATE_USER' then
      begin
        CREATEUSER:=Field.AsString;
      end else
      if FieldName='CREATE_DATE' then
      begin
        CREATEDATE:=Field.AsString;
      end else
      if FieldName='UNDO_USER' then
      begin
        UNDOUSER :=Field.AsString;
      end else
      if FieldName='UNDO_DATE' then
      begin
        UNDODATE :=Field.AsString;
      end else
      if FieldName='OPERATION_NAME' then
      begin
        OPERATIONNAME:=Field.AsString;
      end else
      if FieldName='OPERATION_DATE' then
      begin
        OPERATIONDATE:=Field.AsString;
      end else
      if FieldName='OPERATION_REMARK' then
      begin
        OPERATIONREMARK:=Field.AsString;
      end else
      if FieldName='INIT_MONEY' then
      begin
        INITMONEY:=Field.AsFloat;
      end else
      if FieldName='RESULT_MONEY' then
      begin
        RESULTMONEY:=Field.AsFloat;
      end else
      if FieldName='REMARK' then
      begin
        REMARK   :=Field.AsString;
      end else
      if FieldName='TOLLY_FLAG' then
      begin
        TOLLYFLAG:=Field.AsFloat;
      end else
      if FieldName='BILL_TYPE_CODE' then
      begin
        BILLTYPECODE:=Field.AsString;
      end else
      if FieldName='BILL_ID' then
      begin
        BILLID   :=Field.AsString;
      end else
      if FieldName='RCID' then
      begin
        RCID     :=Field.AsFloat;
      end else
      if FieldName='CCID' then
      begin
        CCID     :=Field.AsFloat;
      end else
      if FieldName='LAST_VER' then
      begin
        LASTVER  :=Field.AsString;
      end else
      if FieldName='SEND_MSG_DATE' then
      begin
        SENDMSGDATE:=Field.AsString;
      end else
      if FieldName='AUTO_AUDIT_DATE' then
      begin
        AUTOAUDITDATE:=Field.AsString;
      end else
      if FieldName='SET_MONTH' then
      begin
        SETMONTH :=Field.AsFloat;
      end else
      if FieldName='UPDATE_FLAG' then
      begin
        UPDATEFLAG:=Field.AsFloat;
      end;
    end
  end;  
end;

class procedure TSYSWFCURRENTTASKS.ReadDS(AUniQuery: TUniQuery; var Result: TUniEngine);
var
  I:Integer;
  Field:TField;
  FieldName:string;
begin
  if Result=nil then Exit;

  with TSYSWFCURRENTTASKS(Result) do
  begin
    for I:=0 to AUniQuery.Fields.Count-1 do
    begin
      Field:=AUniQuery.Fields.Fields[I];
      //if field.fieldname is not all uppercase,please use uppercase().
      FieldName:=Field.FieldName;
      if FieldName='TASK_ID' then
      begin
        TASKID   :=Field.AsFloat;
      end else
      if FieldName='WF_ID' then
      begin
        WFID     :=Field.AsFloat;
      end else
      if FieldName='WF_TABLE_NAME' then
      begin
        WFTABLENAME:=Field.AsString;
      end else
      if FieldName='ENTITY_ID' then
      begin
        ENTITYID :=Field.AsString;
      end else
      if FieldName='CURRENT_NODE_ID' then
      begin
        CURRENTNODEID:=Field.AsFloat;
      end else
      if FieldName='NEXT_NODE_ID' then
      begin
        NEXTNODEID:=Field.AsFloat;
      end else
      if FieldName='ACTION_TYPE_CODE' then
      begin
        ACTIONTYPECODE:=Field.AsString;
      end else
      if FieldName='IS_UNDO' then
      begin
        ISUNDO   :=Field.AsFloat;
      end else
      if FieldName='CREATE_USER' then
      begin
        CREATEUSER:=Field.AsString;
      end else
      if FieldName='CREATE_DATE' then
      begin
        CREATEDATE:=Field.AsString;
      end else
      if FieldName='UNDO_USER' then
      begin
        UNDOUSER :=Field.AsString;
      end else
      if FieldName='UNDO_DATE' then
      begin
        UNDODATE :=Field.AsString;
      end else
      if FieldName='OPERATION_NAME' then
      begin
        OPERATIONNAME:=Field.AsString;
      end else
      if FieldName='OPERATION_DATE' then
      begin
        OPERATIONDATE:=Field.AsString;
      end else
      if FieldName='OPERATION_REMARK' then
      begin
        OPERATIONREMARK:=Field.AsString;
      end else
      if FieldName='INIT_MONEY' then
      begin
        INITMONEY:=Field.AsFloat;
      end else
      if FieldName='RESULT_MONEY' then
      begin
        RESULTMONEY:=Field.AsFloat;
      end else
      if FieldName='REMARK' then
      begin
        REMARK   :=Field.AsString;
      end else
      if FieldName='TOLLY_FLAG' then
      begin
        TOLLYFLAG:=Field.AsFloat;
      end else
      if FieldName='BILL_TYPE_CODE' then
      begin
        BILLTYPECODE:=Field.AsString;
      end else
      if FieldName='BILL_ID' then
      begin
        BILLID   :=Field.AsString;
      end else
      if FieldName='RCID' then
      begin
        RCID     :=Field.AsFloat;
      end else
      if FieldName='CCID' then
      begin
        CCID     :=Field.AsFloat;
      end else
      if FieldName='LAST_VER' then
      begin
        LASTVER  :=Field.AsString;
      end else
      if FieldName='SEND_MSG_DATE' then
      begin
        SENDMSGDATE:=Field.AsString;
      end else
      if FieldName='AUTO_AUDIT_DATE' then
      begin
        AUTOAUDITDATE:=Field.AsString;
      end else
      if FieldName='SET_MONTH' then
      begin
        SETMONTH :=Field.AsFloat;
      end else
      if FieldName='UPDATE_FLAG' then
      begin
        UPDATEFLAG:=Field.AsFloat;
      end;
    end
  end;  
end;

class function  TSYSWFCURRENTTASKS.CopyIt(ASYSWFCURRENTTASKS: TSYSWFCURRENTTASKS): TSYSWFCURRENTTASKS;
begin
  Result:=TSYSWFCURRENTTASKS.Create;
  TSYSWFCURRENTTASKS.CopyIt(ASYSWFCURRENTTASKS,Result)
end;

class procedure TSYSWFCURRENTTASKS.CopyIt(ASYSWFCURRENTTASKS:TSYSWFCURRENTTASKS;var Result:TSYSWFCURRENTTASKS);
begin
  if Result=nil then Exit;
  Result.TASKID   :=ASYSWFCURRENTTASKS.TASKID;
  Result.WFID     :=ASYSWFCURRENTTASKS.WFID;
  Result.WFTABLENAME:=ASYSWFCURRENTTASKS.WFTABLENAME;
  Result.ENTITYID :=ASYSWFCURRENTTASKS.ENTITYID;
  Result.CURRENTNODEID:=ASYSWFCURRENTTASKS.CURRENTNODEID;
  Result.NEXTNODEID:=ASYSWFCURRENTTASKS.NEXTNODEID;
  Result.ACTIONTYPECODE:=ASYSWFCURRENTTASKS.ACTIONTYPECODE;
  Result.ISUNDO   :=ASYSWFCURRENTTASKS.ISUNDO;
  Result.CREATEUSER:=ASYSWFCURRENTTASKS.CREATEUSER;
  Result.CREATEDATE:=ASYSWFCURRENTTASKS.CREATEDATE;
  Result.UNDOUSER :=ASYSWFCURRENTTASKS.UNDOUSER;
  Result.UNDODATE :=ASYSWFCURRENTTASKS.UNDODATE;
  Result.OPERATIONNAME:=ASYSWFCURRENTTASKS.OPERATIONNAME;
  Result.OPERATIONDATE:=ASYSWFCURRENTTASKS.OPERATIONDATE;
  Result.OPERATIONREMARK:=ASYSWFCURRENTTASKS.OPERATIONREMARK;
  Result.INITMONEY:=ASYSWFCURRENTTASKS.INITMONEY;
  Result.RESULTMONEY:=ASYSWFCURRENTTASKS.RESULTMONEY;
  Result.REMARK   :=ASYSWFCURRENTTASKS.REMARK;
  Result.TOLLYFLAG:=ASYSWFCURRENTTASKS.TOLLYFLAG;
  Result.BILLTYPECODE:=ASYSWFCURRENTTASKS.BILLTYPECODE;
  Result.BILLID   :=ASYSWFCURRENTTASKS.BILLID;
  Result.RCID     :=ASYSWFCURRENTTASKS.RCID;
  Result.CCID     :=ASYSWFCURRENTTASKS.CCID;
  Result.LASTVER  :=ASYSWFCURRENTTASKS.LASTVER;
  Result.SENDMSGDATE:=ASYSWFCURRENTTASKS.SENDMSGDATE;
  Result.AUTOAUDITDATE:=ASYSWFCURRENTTASKS.AUTOAUDITDATE;
  Result.SETMONTH :=ASYSWFCURRENTTASKS.SETMONTH;
  Result.UPDATEFLAG:=ASYSWFCURRENTTASKS.UPDATEFLAG;
end;

end.

